//
//  homeTopView.m
//  zhangGuangTianXia
//
//  Created by tangtangchitangtang on 2017/11/10.
//  Copyright © 2017年 tangtangchitangtang. All rights reserved.
//

#import "homeTopView.h"
#import "ShoppingMallVc.h" //商城

@implementation homeTopView
-(void)creatView{

    UIImageView *topImageView=[UIImageView new];
    [self addSubview:topImageView];
    [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(500);
    }];
    topImageView.image=[UIImage imageNamed:@"banner"];

    UIView *topView=[UIView new];
    [self addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(280);
        make.top.mas_equalTo(250);
    }];
    topView.backgroundColor=[UIColor whiteColor];
    topView.layer.cornerRadius=10;
    
    float width=(_mainW-40)/5;
    NSArray *nameArr=[NSArray arrayWithObjects:@"零售商城",@"附近店铺",@"实景商圈",@"阿腾超市",@"代购商品",@"土特产",@"美食",@"酒店住宿",@"休闲娱乐",@"批发商城",@"农业",@"今日活动",@"生活服务",@"便民",@"积分商城", nil];
    int index=0;
    for (int i=0; i<3; i++) {
        for (int j=0; j<5; j++) {
            UIView *tubiao=[UIView new];
            [topView addSubview:tubiao];
            [tubiao mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(j*width);
                make.width.mas_equalTo(width);
                make.top.mas_equalTo(i*80+20);
                make.height.mas_equalTo(80);
            }];
            
            [LYTools viewAddTapWithView:tubiao withTarget:self withAction:@selector(itemClick)];
            
            UIImageView *tuBiaoImage=[UIImageView new];
            [tubiao addSubview:tuBiaoImage];
            [tuBiaoImage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(0);
                make.centerY.mas_equalTo(-20);
                make.width.height.mas_equalTo(40);
            }];
            tuBiaoImage.image=[UIImage imageNamed:nameArr[index]];
            
            UILabel *label=[UILabel new];
            [tubiao addSubview:label];
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(0);
                make.top.mas_equalTo(tuBiaoImage.mas_bottom).mas_equalTo(5);
            }];
            label.font=[UIFont systemFontOfSize:14];
            label.textColor=ColorWithRGB(200, 200, 200);
            label.text=nameArr[index];
             index+=1;
        }
    }
    
    UIView *paoMaDengView=[UIView new];
    [topView addSubview:paoMaDengView];
    [paoMaDengView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(250);
        make.height.mas_equalTo(30);
    }];
    
    UIImageView *imageView=[UIImageView new];
    [paoMaDengView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(20);
    }];
    imageView.image=[UIImage imageNamed:@"掌通头条"];
    
    UIView *xianView=[UIView new];
    [paoMaDengView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *labelView=[UIView new];
    [paoMaDengView addSubview:labelView];
    [labelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
        make.right.mas_equalTo(0);
        make.bottom.top.mas_equalTo(0);
    }];
    
    UILabel *label=[UILabel new];
    [labelView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-10);
    }];
    NSString *Str=@"[2017-06-06]izod最新秋装3折扣起欢迎抢购";
    
    NSMutableAttributedString *AttributedStr= [[NSMutableAttributedString alloc]initWithString:Str];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(252, 74, 82) range:NSMakeRange(0, 11)];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(200, 200, 200) range:NSMakeRange(11, Str.length-11)];
    label.font=[UIFont systemFontOfSize:13];
    label.attributedText=AttributedStr;
    
    
    UIScrollView *scrollView=[UIScrollView new];
    [self addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(15);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(_mainWidth*190/1.5);
    }];
    scrollView.scrollsToTop = NO;
    
    scrollView.showsVerticalScrollIndicator = FALSE;
    scrollView.showsHorizontalScrollIndicator = FALSE;
    scrollView.bounces = NO;
    scrollView.contentSize = CGSizeMake((_mainWidth*190+10)*2+20,0);
    
    for (int i=0; i<2; i++) {
        UIImageView *tuiJian=[UIImageView new];
        [scrollView addSubview:tuiJian];
        [tuiJian mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15+(_mainWidth*190+10)*i);
            make.width.mas_equalTo(_mainWidth*190);
            make.height.mas_equalTo(_mainWidth*190/1.5);
            make.top.mas_equalTo(0);
        }];
        tuiJian.layer.cornerRadius=10;
        tuiJian.layer.masksToBounds=YES;
        tuiJian.image=[UIImage imageNamed:@"组-3"];
    }
    
    UIImageView *dianPuImage=[UIImageView new];
    [self addSubview:dianPuImage];
    [dianPuImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.height.mas_equalTo(45);
        make.top.mas_equalTo(scrollView.mas_bottom).mas_equalTo(-10);
    }];
    dianPuImage.image=[UIImage imageNamed:@"组-6拷贝"];
    
    UIView *dianPuView=[UIView new];
    [self addSubview:dianPuView];
    [dianPuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(dianPuImage.mas_bottom);
        make.height.mas_equalTo(_mainW*1.2);
    }];
    dianPuView.backgroundColor=[UIColor whiteColor];
    
    UIView *xianView2=[UIView new];
    [dianPuView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    UIView *xianView3=[UIView new];
    [dianPuView addSubview:xianView3];
    [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    xianView3.backgroundColor=_LightGrey;
    
    for (int i=0; i<2; i++) {
        for (int j=0; j<2; j++) {
            UIView *beiJingView=[UIView new];
            [dianPuView addSubview:beiJingView];
            [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_mainW/2*j);
                make.height.mas_equalTo(_mainW*0.6);
                make.top.mas_equalTo(_mainW*i*0.6);
                make.width.mas_equalTo(_mainW/2);
            }];
            
            UILabel *lable=[UILabel new];
            [beiJingView addSubview:lable];
            [lable  mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(20);
                make.top.mas_equalTo(15);
                make.right.mas_equalTo(-20);
            }];
            lable.text=@"美国品牌";
            lable.textColor=ColorWithRGB(49, 49, 49);
            lable.font=[UIFont systemFontOfSize:15];
            
            UILabel *biaoQianLabel=[UILabel new];
            [beiJingView addSubview:biaoQianLabel];
            [biaoQianLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.mas_equalTo(lable);
                make.top.mas_equalTo(lable.mas_bottom).mas_equalTo(3);
            }];
            biaoQianLabel.text=@"低音至尚";
            biaoQianLabel.textColor=ColorWithRGB(247, 188, 190);
            biaoQianLabel.font=[UIFont systemFontOfSize:12];
            
            UIImageView *dianImage1=[UIImageView new];
            [beiJingView addSubview:dianImage1];
            [dianImage1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(biaoQianLabel);
                make.width.mas_equalTo(_mainW*0.27);
                make.height.mas_equalTo(_mainW*0.6-100);
                make.top.mas_equalTo(biaoQianLabel.mas_bottom).mas_equalTo(7);
            }];
            dianImage1.backgroundColor=_tianLanColor;
            
            UIImageView *dianImage2=[UIImageView new];
            [beiJingView addSubview:dianImage2];
            [dianImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(dianImage1.mas_right).mas_equalTo(5);
                make.right.mas_equalTo(-10);
                make.height.mas_equalTo(_mainW*0.3-53);
                make.top.mas_equalTo(dianImage1);
            }];
            dianImage2.backgroundColor=_tianLanColor;
            
            
            
            UIImageView *dianImage3=[UIImageView new];
            [beiJingView addSubview:dianImage3];
            [dianImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(dianImage1.mas_right).mas_equalTo(5);
                make.right.mas_equalTo(-10);
                make.height.mas_equalTo(_mainW*0.3-53);
                make.bottom.mas_equalTo(dianImage1);
            }];
            dianImage3.backgroundColor=_tianLanColor;
            
            
            UIImageView *dianImage4=[UIImageView new];
            [beiJingView addSubview:dianImage4];
            [dianImage4 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(dianImage1);
                make.top.mas_equalTo(dianImage1.mas_bottom).mas_equalTo(7);
                make.width.height.mas_equalTo(30);
            }];
            dianImage4.backgroundColor=_tianLanColor;
            
            UILabel *dianJiaLabel=[UILabel new];
            [beiJingView addSubview:dianJiaLabel];
            [dianJiaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(dianImage4.mas_right).mas_equalTo(7);
                make.centerY.mas_equalTo(dianImage4);
                make.right.mas_equalTo(-10);
            }];
            dianJiaLabel.text=@"SK-II 官方旗舰店";
            dianJiaLabel.font=[UIFont systemFontOfSize:13];
            dianJiaLabel.textColor=ColorWithRGB(200, 200, 200);

        }
    }
    
    UIImageView *likeImage=[UIImageView new];
    [self addSubview:likeImage];
    [likeImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.height.mas_equalTo(45);
        make.top.mas_equalTo(dianPuView.mas_bottom).mas_equalTo(-10);
    }];
    likeImage.image=[UIImage imageNamed:@"组-6"];
   
}

#pragma mark————————点击图标
- (void)itemClick
{
    ShoppingMallVc *vc = [[UIStoryboard storyboardWithName:@"ShoppingMallVc" bundle:nil] instantiateViewControllerWithIdentifier:@"ShoppingMallVc"];
    
    [LYTools pushNextViewController:[LYTools getCurrentVC] andRootController:vc];

}


@end
